home *** CD-ROM | disk | FTP | other *** search
- /*
- * Apple Macintosh Developer Technical Support
- **
- ** Program: CShell
- ** File: idletasks.c
- ** Written by: Eric Soldan
- **
- ** Copyright © 1990-1991 Apple Computer, Inc.
- ** All rights reserved.
- */
-
-
-
- /*****************************************************************************/
-
-
-
- #include "CShell.h" /* Get the CShell includes/typedefs, etc. */
- #include "CShellCommon.h" /* Get the stuff in common with rez. */
- #include "CShell.protos" /* Get the prototypes for CShell. */
-
- #ifndef __NOTIFICATION__
- #include <Notification.h>
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __UTILITIES__
- #include "Utilities.h"
- #endif
-
-
-
- /*****************************************************************************/
-
-
-
- static Boolean notifyActive = false;
- static pascal void CancelNotify(NMRecPtr nmReqPtr);
- static NMRec notifyTheUser = {
- nil, /* qLink */
- nmType, /* qType */
- 0, /* nmFlags */
- 0L, /* nmPrivate */
- 0, /* nmReserved */
- 1, /* nmMark */
- nil, /* nmIcon */
- (Handle) -1, /* nmSound */
- nil, /* nmStr */
- nil, /* nmResp */
- 0L /* nmRefCon */
- };
-
- extern RgnHandle gCurrentCursorRgn;
-
-
-
- /*****************************************************************************/
- /*****************************************************************************/
-
-
-
- #pragma segment Main
- void DoIdleTasks(void)
- {
- DynamicBalloonHelp();
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* MyIdleProc
- **
- ** This routine gets either an updateEvt, an activateEvt, a nullEvent or an
- ** OSEvent. The first time called it will get a nullEvent; this is its chance
- ** to set the sleep value and mouseRegion that will be passed to WaitNextEvent
- ** by the caller within the AEM. After that it will also get events of the
- ** other types (which are lost if masked out by the AEM) and must do with them
- ** whatever is appropriate.
- */
-
- #pragma segment Main
- pascal Boolean MyIdleProcBoo(EventRecord *event, long *sleep, RgnHandle *mouseRgn)
- {
- switch (event->what) {
-
- case updateEvt:
- case activateEvt:
- case kOSEvent:
-
- /* These events are passed by the AppleEvent manager to avoid
- dropping while waiting for a reply or notification. Every
- procedure should handle these events in their idle procedure.
- In this code, we simply dispatch these events back to the
- main event loop handling code. */
-
- DoCursor(false, 0);
- DoEvent(event);
- break;
-
-
- case nullEvent:
-
- /* The idle procedure is called once with the null event before
- the loop begins. This allows the application to alter sleep
- time and mouseRgn to meet its own needs. Since we're doing
- nothing, set the cursor to a watch. */
-
- DoCursor(true, 'wait');
-
- *mouseRgn = gCurrentCursorRgn;
- *sleep = 60; /* This is just like the WaitNextEvent
- sleeptime, so use the correct value for
- your application. It's better to use a
- non-zero value here rather than zero,
- as using zero really slows you down. */
-
- /* DoIdle(); */ /* Application's idle handling. */
- break;
-
- default:
- Alert(rErrorAlert, nil);
- break;
- }
- return(false);
- }
-
-
-
- /*****************************************************************************/
-
-
-
- #pragma segment Main
- void NotifyCancel(void)
- {
- if (notifyActive) {
- NMRemove((NMRecPtr)¬ifyTheUser);
- notifyActive = false;
- }
- }
-
-
-
-
- /*****************************************************************************/
-
-
-
- #pragma segment Main
- void NotifyUser(void)
- {
- if (gInBackground) {
- if (!notifyActive) {
- notifyTheUser.nmIcon = GetResource('SICN', 128);
- NMInstall(¬ifyTheUser);
- notifyActive = true;
- }
- }
- }
-
-
-
-